package com.banmao.youZone.util;

import java.security.MessageDigest;

public class MD5Util2 {

    public static final char VERSION_1_2 = '2';
    public static final char VERSION_1_3 = '3';
    public static final char VERSION_1_4 = '4';
    public static final char VERSION_1_5 = '5';
    public static final char VERSION_1_6 = '6';
    public static final char VERSION_1_7 = '7';
    public static final char ATTRIBUTE_TYPE_BYTE = 'B';


    public static final String getMd5Str(String str) {
        char[] cArr = {'0', '1', VERSION_1_2, VERSION_1_3, VERSION_1_4, VERSION_1_5,
                VERSION_1_6, VERSION_1_7, '8', '9', 'A', ATTRIBUTE_TYPE_BYTE, 'C', 'D', 'E', 'F'};
        try {
            byte[] bytes = str.getBytes();
            MessageDigest messageDigest = MessageDigest.getInstance("MD5");
            messageDigest.update(bytes);
            byte[] digest = messageDigest.digest();
            char[] cArr2 = new char[digest.length * 2];
            int i = 0;
            for (byte b : digest) {
                int i2 = i + 1;
                cArr2[i] = cArr[(b >>> 4) & 15];
                i = i2 + 1;
                cArr2[i2] = cArr[b & 15];
            }
            return new String(cArr2).toLowerCase();
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }

}
